<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>直播间用户</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <link href="../../resource/lib/imageview/css/imageviewer.css"
          th:href="@{/resource/lib/imageview/css/imageviewer.css}" rel="stylesheet"/>

    <script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
    <script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
    <script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316"
            th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316(123123)}"></script>
    <script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316"
            th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js}"></script>
    <style>
        .user-close-config {
            height: 40px;
            line-height: 40px;
        }

        .user-close-config .control-label {
            margin-left: 20px;
            font-weight: normal !important;
        }

        .user-close-config label.off {
            background-color: red;
            color: #fff;
            margin-right: 10px;
        }

        .user-close-config label.on {
            background-color: #fff;
            color: #674646;
            border: 1px solid #ccc;
            margin-right: 10px;
        }

        .separator {
            margin: 31px 20px 10px 20px;
            border-bottom: 1px solid #ccc;
        }

        .online-status {
            display: none;
        }
    </style>
</head>

<body>
<div class="wrapper wrapper-content tooltip-demo">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div th:replace="fragments/live_fragment::roomDetailFg" class="ibox-title"
                     style="vertical-align: bottom;height: 100%;padding-left: 0;">
                    <h5 style="font-size: 18px;">
                        <img src="../../resource/img/p2.jpg" onerror="this.src='../../resource/img/d_head.jpeg'"
                             alt="" style="width:100px;height:100px;"/>
                    </h5>
                    <div style="margin-left: 120px;width: 50%;margin-top: -6px;">
                        <h3>剑南的直播间</h3>
                        <p style="width: 373px;height: 51px;">
                            非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间</p>
                        <p>创建时间：2012-12-12 12:12:12</p>
                    </div>
                    <button type="button" onclick="liveHandler.edit()"
                            style="float: right;margin-top: -45px;margin-right: 10px;"
                            class="btn btn-primary btn-xl m-b-none">房间设置
                    </button>
                </div>
                <div class="tabs-container" style="margin-top: 20px;">
                    <ul class="nav nav-tabs">
                        <li>
                            <a th:href="@{/live/detail/products(roomId=${room.id})}" href="user_detail.html">商品管理</a>
                        </li>
                        <li>
                            <a th:href="@{/live/detail/directors(roomId=${room.id})}"
                               href="../user/user_detail_advance_log.html">主播管理</a>
                        </li>
                        <li>
                            <a th:href="@{/live/detail/sessions(roomId=${room.id})}"
                               href="../user/user_detail_advance_log.html">直播记录</a>
                        </li>
                        <li>
                            <a th:href="@{/live/detail/videos(roomId=${room.id})}"
                               href="../user/user_detail_advance_log.html">直接间视频</a>
                        </li>
                        <li sec:authorize="hasRole('ADMIN')">
                            <a th:href="@{/live/detail/images(roomId=${room.id})}"
                               href="../live/live_detail_images.html">直接间图片</a>
                        </li>
                        <li class="active" sec:authorize="hasRole('ADMIN')">
                            <a th:href="@{/live/detail/users(roomId=${room.id})}"
                               href="../live/live_detail_users.html">直接间用户列表</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">
                                <div>
                                    <form role="form" id="searchForm" method="get" th:object="${condition}">
                                        <div class="form-inline">
                                            <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                                            <input type="hidden" th:value="${room.id}" name="roomId"/>
                                            <input type="hidden" th:value="${showOnline}" name="showOnline"/>
                                            <div class="form-group m-r-sm">
                                                <label class=" control-label" for="keyword">直播编号：</label>
                                                <input type="text" class="form-control input-sm mb10" id="keyword"
                                                       name="keyword" th:value="${condition.keyword}"
                                                       placeholder="直播编号，默认当前直播"
                                                       style="width: 190px;"/>
                                            </div>
                                            <div class="form-group m-r-sm">
                                                <label class=" control-label" for="mobile">用户关键字：</label>
                                                <input type="text" class="form-control input-sm mb10" id="mobile"
                                                       name="mobile" th:value="${condition.mobile}"
                                                       placeholder="用户手机号码或昵称"
                                                       style="width: 156px;"/>
                                            </div>
                                            <button type="button" onclick="liveHandler.search(1)"
                                                    class="btn btn-primary btn-sm m-b-none">搜索
                                            </button>
                                        </div>
                                        <div style="height: 20px"></div>
                                    </form>
                                    <div class="table-responsive">

                                        <table class="table table-bordered table-hover table-center">
                                            <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>直播间用户</th>
                                                <th>当前等级</th>
                                                <th class="online-status">在线状态</th>
                                                <th>是否禁言</th>
                                                <th>观看次数</th>
                                                <th class="online-status">观看总时长</th>
                                                <th class="online-status">平均单次时长</th>
                                                <th>首次进入时间</th>
                                                <th class="online-status">最后离开时间</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr th:each="item,stat:${list}">
                                                <td th:text="${stat.count}">1</td>
                                                <td>
                                                    <span th:text="${item.user.nickName}">数农</span>
                                                    <br/>
                                                    <span th:text="${item.user.mobile}">8080800</span>
                                                </td>
                                                <td>
                                                <span class="text-warning"
                                                      th:text="${item.user.userChatLevel.fullLevelName}">LV 0 少侠</span>
                                                </td>
                                                <td class="online-status">
                                                    <span th:if="${item.online}"><i class="fa fa-circle text-warning"></i> 在线</span>
                                                    <span th:if="${!item.online}" style="color:#ccc;"><i
                                                            class="fa fa-circle text-info"></i> 离线</span>
                                                </td>
                                                <td>
                                                    <span th:if="${item.forbid}" style="color: darkred;">已禁言</span>
                                                    <span th:if="${!item.forbid}" style="color:#ccc;">未禁言</span>
                                                </td>
                                                <td>
                                                    <span th:text="${item.enterCount}">0</span> 次
                                                </td>
                                                <td class="online-status">
                                                    <span th:text="${item.totalDuration}">0 秒</span>
                                                </td>
                                                <td class="online-status">
                                                    <span th:text="${item.avgDuration}">0 秒</span>
                                                </td>
                                                <td th:text="${#temporals.format(item.firstEnterTime,'yyyy-MM-dd HH:mm:ss')}">
                                                    2020-09-10 20:00:00
                                                </td>
                                                <td class="online-status">
                                                    <th:block th:if="${!item.online}">
                                                        <span th:text="${#temporals.format(item.lastLeaveTime,'yyyy-MM-dd HH:mm:ss')}">2020-09-10 22:00:00</span>
                                                    </th:block>
                                                </td>
                                                <td>
                                                    <th:block th:if="${room.livePlaying==1}">
                                                        <button th:if="${!item.forbid}" onclick="liveHandler.push(1)"
                                                                th:onclick="liveHandler.forbid([[${item.id}]],true)"
                                                                type="button"
                                                                class="btn btn-danger btn-xs m-b-none"
                                                                style="margin-left: 5px;">禁言
                                                        </button>
                                                        <button th:if="${item.forbid}" onclick="liveHandler.push(1)"
                                                                th:onclick="liveHandler.forbid([[${item.id}]],false)"
                                                                type="button"
                                                                class="btn btn-info btn-xs m-b-none"
                                                                style="margin-left: 5px;">解除禁言
                                                        </button>
                                                    </th:block>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <p style="float: left; margin: 20px 0;">
                                        共<span th:text="${totalRecords}"></span>条记录，当前第<span
                                            th:text="${pageIndex}"></span>/<span
                                            th:text="${totalPages==0?1:totalPages}"></span>，每页<span
                                            onclick="liveHandler.showOnline()" style="cursor: pointer;">20</span>条记录
                                    </p>
                                    <ul style="float: right;" class="pagination pagination-split">
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const showOnline = /*[[${showOnline}]]*/  0;
    const totalPages = /*[[${totalPages}]]*/  0;
    const pageUri = /*[[@{/live/detail/users}]]*/  "";
    const apiUri = /*[[@{/live/detail/users}]]*/  "";
</script>

<script type="text/javascript">
    let clickCount = 0;
    $(function () {
        //初始化分页
        let pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);
        pageinate.init(function (p) {
            liveHandler.search(p);
        });
        if (showOnline === 1) {
            $(".online-status").removeClass("online-status");
        }
    });

    let liveHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        forbid(id, forbid) {
            hot.confirm(forbid ? "是否禁止当前用户发言？" : "是否解除禁言", function () {
                let requestData = {id: id, forbid: forbid};
                hot.ajax(apiUri + "/forbid", requestData, function (apiResult) {
                    if (apiResult.resultCode === 2000) {
                        hot.tip.success("禁言成功", function () {
                            window.location.reload();
                        }, 500);
                    } else {
                        hot.tip.error("禁言失败");
                    }
                }, function () {
                }, "get", 300);
            });
        },
        showOnline() {
            if (clickCount >= 4) {
                $(".online-status").removeClass("online-status");
                $("input[name=showOnline]").val(1);
            }
            clickCount++;
        }
    }
</script>
</body>

</html>